<template>
	<div class="model">
		<h2 class="model__title">申请区域经理详情<span @click="close" class="model__title--close">&times;</span></h2>
		<div class="model__content" v-loading="loading">
			<div v-if="data">
				<div class="item" v-if="data.reject_reason">
					<h2 class="item__title">驳回理由</h2>
					<div class="item__reason">
						{{data.reject_reason}}
					</div>
				</div>
				<div class="item">
					<h2 class="item__title">申请基本信息</h2>
					<div class="item__detail">
						<span class="item__detail--title">申请日期:</span>
						<span class="item__detail--value">{{data.ask_time | formatTime}}</span>
					</div>
				</div>
				<div class="item">
					<h2 class="item__title">用户基本信息</h2>
					<div class="item__detail">
						<span class="item__detail--title">真实姓名:</span>
						<span class="item__detail--value">{{data.member.real_name}}</span>
					</div>
					<div class="item__detail">
						<span class="item__detail--title">身份证号:</span>
						<span class="item__detail--value">{{data.member.id_no}}</span>
					</div>
					<div class="item__detail">
						<span class="item__detail--title">成为推广大使时间:</span>
						<span class="item__detail--value">{{data.member.be_saleman_time | formatTime }}</span>
					</div>
					<div class="item__detail">
						<span class="item__detail--title">注册时间:</span>
						<span class="item__detail--value">{{data.member.regist_time | formatTime}}</span>
					</div>
					<div class="item__detail">
						<span class="item__detail--title">手机号:</span>
						<span class="item__detail--value">{{data.member.mobile}}</span>
					</div>
				</div>
				<div class="item">
					<h2 class="item__title">推荐人信息</h2>
					<div v-if="data.manager_spreader">
						<div class="item__detail">
							<span class="item__detail--title">姓名:</span>
							<span class="item__detail--value">{{data.manager_spreader.real_name}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">身份证号:</span>
							<span class="item__detail--value">{{data.manager_spreader.id_no}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">手机号:</span>
							<span class="item__detail--value">{{data.manager_spreader.mobile}}</span>
						</div>
					</div>
					<div v-else>
						无
					</div>
				</div>
				<div class="item">
					<h2 class="item__title">申请理由</h2>
					<div class="item__reason">
						{{data.ask_reason}}
					</div>
				</div>
				<div class="item">
					<h2 class="item__title">图片信息</h2>
					<div class="item__detail-pic" v-for="item in data.ask_res">
						<img :src="item.thump + '400'" @click="showBigImg(item.url)"/>	
					</div>
				</div>
				<div class="item">
					<h2 class="item__title">申请区域</h2>
					<div v-if="ask_area_names" v-for="item in ask_area_names">{{item}}</div>
				</div>
				<div class="item">
					<h2 class="item__title">负责区域</h2>
					<div v-if="area_names" v-for="item in area_names">{{item}}</div>
				</div>
			</div>
			<big-img v-if="isShowBigImg" :imgUrl="bigImgUrl"></big-img>
		</div>
	</div>
</template>

<script>
	import big_img from "../../../components/big_img.vue"
	export default {
		created(){
			this.fetchManagerInfo();
		},
		components: {
			"big-img": big_img,
		},
		props: ["id"],
		data() {
			return {
				loading: true,
				isShowBigImg: false,
				data: null
			}
		},
		methods: {
			showBigImg(imgUrl) {
				this.bigImgUrl = imgUrl;
				this.isShowBigImg = true;
			},
			close() {
				this.$parent.showModel = false;
			},
			fetchManagerInfo() {
				this.loading = true;
				var url = `${this.url}/spread/check_be_manager_info.action`;
				var params = {
					token: "3960c4db11d44c018898258d63d95bd0",
					be_saleman_id: this.id
				};
				this.$http.get(url,{ params }).then((res)=> {
					this.loading = false;
					this.data = res.data.result;
					// 申请区域
					var ask_area_names = [];
					if(this.data.ask_areas) {
						this.data.ask_areas.forEach(function(r) {
							var ask_area_name = '';
							r.ask_area.forEach(function(r2) {
								if(r2.area_name)
									ask_area_name = r2.area_name + ask_area_name;
							})
							ask_area_names.push(ask_area_name);
						})
					}
					this.ask_area_names = ask_area_names;
					// 负责区域
					var area_names = [];
					if(this.data.areas) {
						this.data.areas.forEach(function(r) {
							var area_name = '';
							r.area.forEach(function(r2) {
								if(r2.area_name)
									area_name = r2.area_name + area_name;
							})
							area_names.push(area_name);
						})
					}
					this.area_names = area_names;
				});
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>